package cn.ecnu.paper.mapper;

import cn.ecnu.paper.pojo.Collection;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface CollectionMapper {

    int addClt(Collection collection);

    @Update("UPDATE collection SET flag = 0 WHERE user_id = #{uid} AND paper_id = #{pid}")
    int unCollect(@Param("uid") Integer userId, @Param("pid") Integer paperId);

    @Select("SELECT COUNT(*) FROM collection WHERE user_id = #{uid} AND flag = 1")
    Integer getCollectionCountByUid(Integer uid);
}
